feat: add max_votes_per_option support to amaci circuits, sdk and con…#23
Open
99Kies wants to merge 10 commits into
Open
feat: add max_votes_per_option support to amaci circuits, sdk and con…#2399Kies wants to merge 10 commits into
99Kies wants to merge 10 commits into
Conversation
…tracts - add maxVotesPerOption signal to messageValidator/stateLeafTransformer/processMessages circuits (amaci/power) - pack maxVotesPerOption into the 4th 32-bit slot of packedVals (bits 96-127), 0 = unlimited (backward compatible) - sdk: operator.ts/voter.ts/contract.ts support configuring and validating maxVotesPerOption - contracts: amaci/registry/api-saas msg/state/contract updated to store, validate and query max_votes_per_option - regenerate test-scale (2-1-1-5) zkey/vkey and logs.json fixtures to match the updated circuits - add circuit unit tests (MessageValidator/StateLeafTransformer/ProcessMessages) and a full-round contract test driven by real generated proofs - fix generate-logs.ts: REQUIRED_REMOTE_ARTIFACTS was evaluated at module load before its referenced vars were assigned NOTE: production-scale (9-4-3-125) vkey/zkey has NOT been regenerated; a real trusted setup ceremony is still required before this can be deployed to production rounds.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Regenerate AMaci/Registry/ApiSaas schema JSON and generated TS client/types files (both contracts/*/ts and packages/sdk copies) so the max_votes_per_option field/query added earlier is reflected in the auto-generated bindings. Verified the two generated copies are byte-identical (pre-existing Uint64 number/string discrepancy in Registry.types.ts predates this change) and that packages/sdk builds cleanly (tsc --build + tsup).
- amaci: add ExecuteMsg::SetMaxVotesPerOption, restricted the same way as SetRoundInfo (admin-only, only before voting starts); extract the 32-bit bound check into a shared validate_max_votes_per_option used by both instantiate and the new update path - api-saas: add SetMaxVotesPerOption proxy execute msg (operator-gated, forwards to the target amaci round which enforces its own admin+timing checks) - regenerate amaci/api-saas JSON schema and cosmwasm-ts-codegen TS client/types (both contracts/*/ts and packages/sdk mirrors) - sdk: add setApiSaasMaciRoundMaxVotesPerOption and getMaxVotesPerOption to packages/sdk/src/libs/contract/contract.ts - amaci multitest: add set_max_votes_per_option helper and 5 tests covering success-before-voting, PeriodError after/at voting start, Unauthorized for non-admin, and MaxVotesPerOptionExceeded on update
… on created_round event - sdk: createApiSaasAmaciRound now forwards max_votes_per_option to the contract, matching createAMaciRound - amaci: InstantiationData reply payload now reports max_votes_per_option back to Registry (Option + serde default for backward compatibility with older amaci code IDs) - registry: reply_created_round now emits a max_votes_per_option attribute (defaults to "0") so indexers can pick it up on round creation
- Update vkeys for both 2-1-1-5 (test) and 9-4-3-125 (production) circuits in contracts/amaci/src/circuit_params.rs - Sync vkeys and zkeyUrl (v5 -> v6) in packages/cli/src/core/circuits.ts, update SHA256 hashes for both tar archives - Update S3 download URLs and internal tar paths (v5 -> v6) in e2e/scripts/downloadZkeys.ts and packages/circuits/ts/generate-logs.ts - Refresh e2e/circuits/vkeys-amaci-2-1-1-5.json with v6 vkey values - Regenerate logs.json for amaci and registry contract tests
The v6 AMACI zkey tarball extracts flat into the circuits dir (no "2-1-1-5/" wrapper sub-directory like v5 did). findExtractedZkeyDir only scanned sub-directories for artifacts, so on a flat layout it fell back to a hardcoded prefix and failed with "Required file not found" in CI (this was never hit locally since the extraction was done manually there, bypassing the script's own logic). - findExtractedZkeyDir now also checks baseDir itself before recursing into sub-directories - Fix downstream logging/cleanup to handle an empty-array prefix (flat layout) without touching undefined paths or the whole circuits dir - Remove loose copied source files after organizing when the archive extracted flat, so they don't linger or get mistaken for a valid extraction on a future run
cw_amaci, cw_amaci_registry and cw_api_saas embed the v6 vkey constants from circuit_params.rs, so their optimized release wasm changed and needs updated checksums. cw_maci/cw_test are unaffected.
Document the end-to-end design of the max_votes_per_option feature across circuits (messageValidator/stateLeafTransformer/processMessages), contracts and SDK, including packedVals bit-packing, edge cases and security analysis.
Regenerated types.ts removed the full-data pre-deactivate endpoint
(GET /v1/pre-deactivate/{contractAddress}) in favor of the K-anonymous
/meta + /proof split, and added set-max-votes-per-option / health/pools
/ pre-deactivate pool-status endpoints. Adapt the SDK accordingly:
- client.ts: drop the now-nonexistent getPreDeactivate (fixes a type
error), add getHealthPools, getPreDeactivatePoolStatus and
setMaxVotesPerOption
- voter.ts: saasGetPreDeactivate now calls getPreDeactivateMeta instead
of the removed endpoint; saasVote passes maxVotesPerOption through to
buildVotePayload for client-side fail-fast validation
- maci.ts: add saasSetMaxVotesPerOption wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…tracts